import React from 'react'
import { Route, Switch, Redirect } from 'react-router-dom'

export default function Root({ routes }) {
    return (
        <>
            {
                routes.map((item, index) => {
                    return <Route
                        path={item.path}
                        render={() => {
                            // 先判断需不需要拦截
                            if (item.auth) {
                                return <Redirect to="/login" />
                            } else {
                                let Com = item.component
                                return <Com child={item.child} />
                            }
                        }}
                        key={index} />
                })
            }
        </>
    )
}
